package com.zyd.recyclerviewdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class RefreshRecycleAdapter extends RecyclerView.Adapter<RefreshRecycleAdapter.ViewHolder> {

    private List<String> list;

    private Context context;

    public RefreshRecycleAdapter(Context context, List<String> list) {

        this.context = context;
        this.list = list;

    }

    @Override

    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_expandable_list_item_1, parent, false);

        ViewHolder viewHolder = new ViewHolder(view);

        return viewHolder;

    }

    @Override

    public void onBindViewHolder(ViewHolder holder, int position) {

        holder.text.setText(list.get(position));

        holder.itemView.setTag(position);

    }

    @Override

    public int getItemCount() {

        return list.size();

    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private TextView text;

        public ViewHolder(View itemView) {

            super(itemView);

            text = itemView.findViewById(android.R.id.text1);

        }

    }

}